<%@ page language="java" contentType="text/html; charset=UTF-8"
         pageEncoding="UTF-8" %>
<%@taglib prefix="s" uri="/struts-tags" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <title>拖车业务模板查询</title>
    <s:head/>
</head>
<script type="text/javascript">
    var formSetting = {
        title: "拖车业务历史数据查询",
        module: 'query',
        columns: [{
            name: "trailState",
            label: "业务状态",
            type: "dropdown",
            dropdownType: "ajax",
            url: "../base/dropdown-trailState",
            op: "eq",
            minLength: 0,
            hidden: true
        }, {
            name: "confirmTime",
            label: "业务提交时间从",
            type: "date",
            op: "ge",
            hidden: true
        }, {
            name: "confirmTime",
            label: "到",
            type: "date",
            op: "le",
            hidden: true
        }, {
            name: "commonTemplateName",
            label: "模板名称"
        }, {
            name: "creator",
            label: "模板保存人"
        }, {
            name: "supCompany.id",
            label: "业务代理人",
            type: "dropdown",
            dropdownType: "ajax",
// 			url : "../base/dropdown-selfSupCop",
            url: "../base/dropdown-findCompanysByNameType?com_type=CC&sup_type=C",
            op: "eq",
            minLength: 0
        }],
        buttons: {
            custom: [
                {
                    id: "delBtn", value: "删除", click: function () {
                    var selectedRowId = $("#trailsDataGrid").getGridParam("selrow");
                    if (selectedRowId) {
                        var selectedRow = $("#trailsDataGrid").getRowData(selectedRowId);
                        if (confirm("确定要删除选择的项?")) {
                            $.post("trail-delTemplate", "id=" + selectedRow.id, function (data) {
                                var msg = $.parseJSON(data.msg);
                                if (msg.state == "1") {
                                    $("#trailsDataGrid").jqGrid("setGridParam",
                                            {
                                                search: true
                                                // 将jqGrid的search选项设为true
                                            }).trigger("reloadGrid", [{
                                        page: 1
                                    }]);
                                    jw.alert(msg.msg);
                                } else {
                                    jw.alert(msg.msg);

                                }
                            });
                        }
                    }
                    else {
                        jw.alert("请点击需要操作的数据!");
                    }
                }
                }, {
                    id: "query", value: "导入", click: function () {
                        var selectedRowId = $("#trailsDataGrid").getGridParam("selrow");
                        if (selectedRowId) {
                            var selectedRow = $("#trailsDataGrid").getRowData(selectedRowId);
                            parent.loadBizFromHistoryData(selectedRow.businessId, "trail");

                            jw.close();

                        }
                        else {
                            jw.alert("请点击需要操作的数据!");
                        }
                    }
                }
            ]
        },
        grid: {
            id: "trailsDataGrid",
            title: "查询结果",
            autowidth: false,
            url: "trail-findList?loadPage=${loadPage}",
            /* postData : {
             "pid" : pid
             }, */
            colModel: [{
                index: "ID",
                name: "id",
                hidden: true
            }, {
                index: "businessId",
                name: "businessId",
                label: "业务编号",
                hidden: true
            }, {
                index: "commonTemplateName",
                name: "commonTemplateName",
                width: 300,
                label: "模板名称"
            }, {
                index: "pi",
                name: "pi",
                label: "PI号",
                hidden: true
            }, {
                index: "creator",
                name: "creator",
                width: 300,
                label: "模板保存人"
            }, {
                index: "supNAME",
                name: "supCompany.name",
                width: 300,
                label: "业务代理人"
            }, {
                index: "shipper",
                name: "shipper.company",
                width: 300,
                label: "实际托运人",
                hidden: true
            }, {
                index: "confirmTime",
                name: "confirmTime",
                label: "业务提交时间",
                formatter: 'date',
                formatoptions: {srcformat: 'Y-m-d H:i:s', newformat: 'Y-m-d H:i:s'},
                hidden: true
            }, {
                index: "validateState",
                name: "trailState",
                label: "业务状态",
                hidden: true
            }/* , {
             index : "en",
             name : "en",
             label : "英文名"
             }, {
             index : "identifier",
             name : "identifier",
             label : "标识符"
             }, {
             index : "use_state",
             name : "use_state",
             label : "使用状态",
             formatter : function(cellvalue, options, rowObject) {
             if (cellvalue == "0") {
             return "启用";
             } else {
             return "禁用";
             }
             }
             }, {
             index : "updateUser",
             name : "updateUser",
             label : "修改人"
             }, {
             index : "updateDate",
             name : "updateDate",
             label : "修改时间"
             }  */],
            sortname: "businessId",
            sortorder: "desc",
            jsonReader: {
                root: "trails"
            }
        }
    };
    $(document).ready(function () {
        $("#trailsDataTable").mrdForm(formSetting);
    });
</script>
<body>
<div id="trailsDataTable"></div>
</body>
</html>
